package com.gwt.material.client.user.service.impl;

import com.gwt.boot.constant.CommonEnum;
import com.gwt.material.client.user.dao.UserMapper;
import com.gwt.material.client.user.po.User;
import com.gwt.material.client.user.service.UserService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public User getUserByPhone(String phone) {
        QueryWrapper queryWrapper = QueryWrapper.create(User.class);
        queryWrapper.eq(User :: getPhone, phone);
        return this.getOne(queryWrapper);
    }

    @Override
    public void createUser(User user) {
        //默认值
        user.setStatus(CommonEnum.ENABLE.getCode());
        this.save(user);
    }
}
